import { defineConfig } from "vite"
import vue2 from "@vitejs/plugin-vue2"
import { createHtmlPlugin } from "vite-plugin-html"
import ViteSvgIcons from 'vite-plugin-svg-icons'
import path from "path"
import settings from "./src/settings"

export default defineConfig({
  plugins: [
    vue2(),
    ViteSvgIcons({
      iconDirs: [path.resolve(__dirname, 'src/icons/svg')],
      symbolId: 'icon-[name]'
    }),
    createHtmlPlugin({
      inject: {
        data: {
          page_title: settings.title
        }
      }
    })
  ],
  // css: {
  //   preprocessorOptions: {
  //     sass: {
  //       additionalData: `@import "@/styles/mixin.scss"; @import "@/styles/variables.module.scss";`
  //     }
  //   }
  // },
  // server: {
  //   host: "localhost",
  //   port: 9527,
  //   https: false,
  //   open: true,
  //   proxy: {
  //     "^/api": {
  //       target: "http://localhost:9999",
  //       changeOrigin: true, //允许跨域
  //       rewrite: path => path.replace(/^\/api/, "")
  //     }
  //   }
  // },
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src")
    },
    extensions: [".vue", ".js", ".css"]
  }
})
